package org.example;

import com.microsoft.kiota.authentication.ApiKeyAuthenticationProvider;
import com.microsoft.kiota.authentication.ApiKeyLocation;
import com.microsoft.kiota.http.OkHttpRequestAdapter;
import io.github.zzhorizonzz.client.models.User;
import io.github.zzhorizonzz.sdk.ClerkClient;
import io.github.zzhorizonzz.sdk.jwk.JWKService;
import io.github.zzhorizonzz.sdk.jwt.JWTService;
import io.github.zzhorizonzz.sdk.jwt.VerifyTokenOptions;
import io.github.zzhorizonzz.sdk.session.SessionClaims;
import io.github.zzhorizonzz.sdk.user.UserService;
import io.github.zzhorizonzz.sdk.user.request.ListAllUsersRequest;
import okhttp3.OkHttp;
import org.jose4j.jwk.JsonWebKey;
import org.jose4j.jwk.JsonWebKeySet;
import org.jose4j.jwt.JwtClaims;
import org.jose4j.jwt.consumer.JwtConsumer;
import org.jose4j.jwt.consumer.JwtConsumerBuilder;

import java.security.PublicKey;
import java.util.List;

public class Main {
    public static String sk = "Bearer sk_test_aATqTcQWXrVovlw4WT1y5PjjrYIPbLyuVr0EqmBfe0";
    public static String urlPrefix = "https://api.clerk.com/v1";

    public static String headerParam = "authorization";

    public static String jwt = "eyJhbGciOiJSUzI1NiIsImNhdCI6ImNsX0I3ZDRQRDExMUFBQSIsImtpZCI6Imluc18yY3pHNFI0bkpNOU04aVRPbndRbUJLUDJGY24iLCJ0eXAiOiJKV1QifQ.eyJhenAiOiJodHRwOi8vbG9jYWxob3N0OjUxNzMiLCJleHAiOjE3MDkxMzI2NzIsImlhdCI6MTcwOTEzMjYxMiwiaXNzIjoiaHR0cHM6Ly9tb3ZlZC1rcmlsbC01MS5jbGVyay5hY2NvdW50cy5kZXYiLCJuYmYiOjE3MDkxMzI2MDIsInNpZCI6InNlc3NfMmN6U05iMWZxcGZPMDJnZzhDSmgwRXZUbmNqIiwic3ViIjoidXNlcl8yY3pTTmFwV3J6SEFtQklOdUFnQ1lRSzQxSlYifQ.Shj3VuXnCZVPu9bhoTlLCzT_CnrND6L9sQw074RNHHYPqhOMUntoZTF_Red78sNPKXnrlhSxpsaGGXUqGk2beoUhovDhnHySbLsBF2H5MxYsEvAKjVRsxj2EDnjr-9P6d6z-VVqBtYqWcW19lC-X0gIZtIiQDvzfPsiHmmZvpkabVxSPl36vuFGUM-B8l2arPuRdym6fBVoIbLZvihWneoEYfldvUt2VfpC0FsnuSRdcj6YdcUDL3RDtbNlxSKtW2AMmw4Sd8Vjyq-0wceYh7DrXAm3wdEFAi8jxowaK8vlN5ctwb_Wha84qZgRLK-QW7vmnqkC6RSQCl3-H9Xt2MA";
    public static void main(String[] args) throws Exception {
        System.out.println("Hello world!");
        ApiKeyAuthenticationProvider authProvider = new ApiKeyAuthenticationProvider(sk, "Authorization", ApiKeyLocation.HEADER, "https://api.clerk.com/v1");
        OkHttpRequestAdapter adapter = new OkHttpRequestAdapter(authProvider);
        ClerkClient client = new ClerkClient(adapter);
        JWKService jwksService = client.getJwksService();
        JWTService jwtService = client.getJwtService();
        JsonWebKeySet jsonWebKeySet = jwksService.listAll();
//        UserService userService = client.getUserService();
//        List<User> users = userService.listAll(new ListAllUsersRequest());

//        JWTService jwtService = client.getJwtService();
        VerifyTokenOptions options = new VerifyTokenOptions();
        SessionClaims sessionClaims = jwtService.verifyToken(jwt,options);
//        System.out.println(sessionClaims);
    }
}